class CreateMessages < ActiveRecord::Migration
  def self.up
    # I'm not very familiar with migrate,
    # so do the work dirty by using raw SQL.
    # Only works for MySQL!
    execute "CREATE TABLE messages (
      id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
      user_id INT NOT NULL,
      content VARCHAR(500) NOT NULL,
      post_at DATETIME NOT NULL,
      FOREIGN KEY (user_id) REFERENCES users (id)
    );"
  end

  def self.down
    drop_table :messages
  end
end
